//获取首页文章数据
const db=require("../lib/db")
function homeArticle(){
    return new Promise((resolve,reject)=>{
        //定义查询的sql
    let sql="select * from essay";
    db.querySql(sql).then(data=>{
        if(data.length==0){
            //返回状态码
            resolve(4001)
        }else{
            let arr2=[]
            data.map(element=>{
                // console.log(element)
                arr2.push({       _id:Buffer.from(String(element._id)).toString("base64"),
                    title:element.title,
                    desc2:element.desc,
                    author:element.author,
                    authorId:element.authorId,
                    classify:element.classify,
                    content:element.content
            })
            })
            resolve(arr2)
        }
    })
})
}
//导出
module.exports=homeArticle